﻿/*
    Function: My Dialog
    Author:   Master HaKu(David Gu)
    Date:     2012/08/28
*/

//Callback Function of Confirm Dialog
var G_ConfirmCallback = {
    ConfirmFunc: function () {
        
    }
}

/*
    Confirm Dialog
*/

function G_ConfirmDialog(id, title, msg, type) {
    this.boxId = id;
    this.boxTitle = title;
    this.boxMsg = msg;
    this.boxUI = "<div id='" + this.boxId + "' title='" + this.boxTitle + "'>"
                + "<center><div class='dialog_content'>" + this.boxMsg + "</div></center></div>";
    this.boxType = type;
}

G_ConfirmDialog.prototype.Init = function() {
    $(this.boxUI).appendTo("body");

    var box_height = 200;
    var box_width = 250;

    switch (this.boxType) {
    case "small":
        box_height = 200;
        box_width = 250;
        break;
    case "medium":
        box_height = 300;
        box_width = 400;
        break;
    case "large":
        box_height = 600;
        box_width = 800;
        break;
    default:
        box_height = 200;
        box_width = 250;
    }

    $("#" + this.boxId).dialog({
        autoOpen: false,
        height: box_height,
        width: box_width,
        modal: true,
        buttons: {
            "Yes": function() {
                G_ConfirmCallback.ConfirmFunc();

                $(this).dialog("close");
            },
            "No": function() {
                $(this).dialog("close");
            }
        }
    });
}

G_ConfirmDialog.prototype.Show = function () {
    $("#" + this.boxId).dialog("open");
}


/*
    Simple Dialog
*/

function G_SimpleDialog(id, title, msg, type) {
    this.boxId = id;
    this.boxTitle = title;
    this.boxMsg = msg;
    this.boxUI = "<div id='" + this.boxId + "' title='" + this.boxTitle + "'>"
                + "<center><div class='dialog_content'>" + this.boxMsg + "</div></center></div>";
    this.boxType = type;
}

G_SimpleDialog.prototype.Init = function () {
    $(this.boxUI).appendTo("body");

    var box_height = 200;
    var box_width = 250;

    switch (this.boxType) {
        case "small":
            box_height = 200;
            box_width = 250;
            break;
        case "medium":
            box_height = 300;
            box_width = 400;
            break;
        case "large":
            box_height = 600;
            box_width = 800;
            break;
        default:
            box_height = 200;
            box_width = 250;
    }

    $("#" + this.boxId).dialog({
        autoOpen: false,
        height: box_height,
        width: box_width,
        modal: true,
        buttons: {
            "Ok": function () {
                $(this).dialog("close");
            }
        }
    });
}

G_SimpleDialog.prototype.Show = function() {
    $("#" + this.boxId).dialog("open");
}


/*
    Content Dialog
*/

function G_ContentDialog(id, title, contentId, type) {
    this.boxId = id;
    this.boxTitle = title;
    this.contentId = contentId;
    this.boxUI = "<div id='" + this.boxId + "' title='" + this.boxTitle + "'>"
                + "<div id='" + this.contentId + "' class='dialog_content'></div></div>";
    this.boxType = type;
}

G_ContentDialog.prototype.Init = function() {
    $(this.boxUI).appendTo("body");

    var box_height = 580;
    var box_width = 660;

    switch (this.boxType) {
    case "medium":
        box_height = 580;
        box_width = 660;
        break;
    case "large":
        box_height = 750;
        box_width = 1000;
        break;
    default:
        box_height = 580;
        box_width = 660;
    }

    $("#" + this.boxId).dialog({
        autoOpen: false,
        height: box_height,
        width: box_width,
        modal: true,
        buttons: {
            
        }
    });
}

G_ContentDialog.prototype.LoadContent = function (url) {
    var contId = this.contentId;

    $.get(url, function(data) {
        //alert("Show Content Url: " + url);

        $("#" + contId).html(data);
    });
}

G_ContentDialog.prototype.Show = function () {
    $("#" + this.boxId).dialog("open");
}
